package com.study.controller;

import com.github.pagehelper.PageInfo;
import com.study.entity.Product;
import com.study.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Product)表控制层
 *
 * @author dujun
 * @since 2020-10-20 11:02:37
 */
@Controller
@RequestMapping("product")
public class ProductController {
    /**
     * 服务对象
     */
    @Resource
    private ProductService productService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */

    @GetMapping("findAll")
    public ModelAndView findAll(Integer page,Integer size) {
        PageInfo<Product> pageInfo = productService.findAll(page, size);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("product-list");
        modelAndView.addObject("listP",pageInfo);
        return modelAndView;
    }
}